package com.cskaoyan.service;

import com.cskaoyan.bean.GoodsExample;
import com.cskaoyan.bean.GoodsProductExample;
import com.cskaoyan.bean.OrderExample;
import com.cskaoyan.bean.UserExample;
import com.cskaoyan.mapper.GoodsMapper;
import com.cskaoyan.mapper.GoodsProductMapper;
import com.cskaoyan.mapper.OrderMapper;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.vo.DashboardVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 功能:首页
 * 作者:whj
 */
@Service
public class DashboardServicelmpl implements DashboardService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    GoodsProductMapper goodsProductMapper;
    @Autowired
    OrderMapper orderMapper;


    @Override
    public DashboardVo page() {
        DashboardVo dashboardVo = new DashboardVo();
        long userTotal = userMapper.countByExample(new UserExample());
        long goodsTotal = goodsMapper.countByExample(new GoodsExample());
        long productTotal = goodsProductMapper.countByExample(new GoodsProductExample());
        long orderTotal = orderMapper.countByExample(new OrderExample());
        dashboardVo.setUserTotal((int) userTotal);
        dashboardVo.setGoodsTotal((int) goodsTotal);
        dashboardVo.setProductTotal((int) productTotal);
        dashboardVo.setOrderTotal((int) orderTotal);
        return dashboardVo;
    }
}
